<template>
  <div class="modern-card" :style="{ background: cardColor }">
    <div class="card-icon">
      <slot name="action" />
    </div>
    <div class="card-content">
      <div class="card-title">
        <slot name="title">
          {{ title }}
        </slot>
      </div>
      <div class="card-subtitle">
        <slot name="subtitle">
          {{ subtitle }}
        </slot>
      </div>
      <div class="card-total">
        <slot name="total">
          <span>{{ typeof total === 'function' && total() || total }}</span>
        </slot>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'ChartCard',
  props: {
    title: {
      type: String,
      default: ''
    },
    subtitle: {
      type: String,
      default: ''
    },
    total: {
      type: [Function, Number, String],
      required: false,
      default: null
    },
    loading: {
      type: Boolean,
      default: false
    },
    cardColor: {
      type: String,
      default: '#1890ff'
    }
  }
}
</script>

<style lang="scss" scoped>
.modern-card {
  position: relative;
  padding: 20px;
  border-radius: 16px;
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;

  &:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
  }

  .card-icon {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;

    i {
      font-size: 20px;
      color: white;
    }
  }

  .card-content {
    flex: 1;

    .card-title {
      font-size: 18px;
      font-weight: bold;
      margin-bottom: 8px;
      color: white;
    }

    .card-subtitle {
      font-size: 14px;
      opacity: 0.9;
      margin-bottom: 12px;
      color: white;
    }

    .card-total {
      font-size: 24px;
      font-weight: bold;
      color: white;
    }
  }
}
</style>
